import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/constants.dart';
import 'package:ichinesereader/controller/reports.dart';
import 'package:ichinesereader/routes/routePages.dart';
import 'package:ichinesereader/themes/pageStyles.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:ichinesereader/widgets/layouts/appdrawerSchoolAdmin.dart';
import 'package:ichinesereader/widgets/layouts/customAppBar.dart';
import 'package:ichinesereader/widgets/sidebars/adminSidebar.dart';
import '../../themes/appTheme.dart';

class SchoolAdminReports extends StatefulWidget {
  static const String routeName = '/schooladmin/reports';

  @override
  State<SchoolAdminReports> createState() => _SchoolAdminReportsState();
}

class _SchoolAdminReportsState extends State<SchoolAdminReports> {
  // final List<PhotoItem> _items = [
  //   PhotoItem("assets/images/reports/schoolReports.png", "School Reports", ''),
  //   PhotoItem("assets/images/reports/classReports.png", "Class Reports", ''),
  //   PhotoItem(
  //       "assets/images/reports/studentReports.png", "Student Reports", ''),
  // ];

  @override
  void initState() {
    Get.lazyPut(() => ReportsController());
    super.initState();
  }

  @override
  void dispose() {
    Get.delete<ReportsController>();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    Log.debug('build report Admin Home Page');

    int _selectedSidebarItem = RoutePages.schoolAdminPageItems
        .indexWhere((page) => page.route == Get.currentRoute);
    final isSmallScreen =
        MediaQuery.of(context).size.width < Constants.DefinedScreenSmallSize;
    final isMediumScreen =
        MediaQuery.of(context).size.width < Constants.DefinedScreenMediumSize;
    final isBigScreen =
        MediaQuery.of(context).size.width > Constants.DefinedScreenBigSize;
    final PageStyles _pageStyles = PageStyles();

    return Scaffold(
      appBar: isSmallScreen ? CustomAppBar(title: 'Reports'.tr) : null,
      drawer: isSmallScreen ? SchoolAdminAppDrawer() : null,
      body: Container(
        decoration: _pageStyles.pageBoxDecoration(),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Visibility(
                visible: !isSmallScreen,
                child: AdminSidebarX(
                    selectedIndex: _selectedSidebarItem,
                    isBigScreen: isBigScreen)),
            Expanded(
              child: isMediumScreen
                  ? Container(
                      margin: _pageStyles.mainContainerPageEdgeInsets(),
                      decoration: _pageStyles.dataGridBackground(),
                      child: Column(
                        children: [
                          Expanded(
                            child: Container(
                              width: double.infinity,
                              padding: EdgeInsets.all(12.0),
                              decoration: BoxDecoration(
                                  color: Get.isDarkMode
                                      ? AppTheme.colors.darkTheme2
                                      : Colors.white.withOpacity(0.3),
                                  borderRadius: BorderRadius.circular(6.0)),
                              child: GestureDetector(
                                  child: Image.asset(
                                      "assets/images/reports/schoolReports.png"),
                                  onTap: () {
                                    Get.toNamed('/schooladmin/reports/overall');
                                  }),
                            ),
                          ),
                          Expanded(
                            child: Container(
                              width: double.infinity,
                              margin: EdgeInsets.symmetric(vertical: 9.0),
                              padding: EdgeInsets.all(12.0),
                              decoration: BoxDecoration(
                                  color: Get.isDarkMode
                                      ? AppTheme.colors.darkTheme2
                                      : Colors.white.withOpacity(0.3),
                                  borderRadius: BorderRadius.circular(6.0)),
                              child: GestureDetector(
                                  child: Image.asset(
                                      "assets/images/reports/classReports.png"),
                                  onTap: () {
                                    Get.toNamed('/schooladmin/reports/class');
                                  }),
                            ),
                          ),
                          Expanded(
                            child: Container(
                              width: double.infinity,
                              padding: EdgeInsets.all(12.0),
                              decoration: BoxDecoration(
                                  color: Get.isDarkMode
                                      ? AppTheme.colors.darkTheme2
                                      : Colors.white.withOpacity(0.3),
                                  borderRadius: BorderRadius.circular(6.0)),
                              child: GestureDetector(
                                  child: Image.asset(
                                      "assets/images/reports/studentReports.png"),
                                  onTap: () {
                                    Get.toNamed('/schooladmin/reports/student');
                                  }),
                            ),
                          ),
                        ],
                      ),
                    )
                  : Container(
                      margin: _pageStyles.mainContainerPageEdgeInsets(),
                      decoration: _pageStyles.dataGridBackground(),
                      child: Column(
                        children: [
                          Expanded(
                            child: Row(
                              children: [
                                Expanded(
                                  child: Container(
                                    margin: EdgeInsets.all(12),
                                    padding: EdgeInsets.all(15.0),
                                    decoration: BoxDecoration(
                                        color: Get.isDarkMode
                                            ? AppTheme.colors.darkTheme2
                                            : Colors.white.withOpacity(0.3),
                                        borderRadius:
                                            BorderRadius.circular(6.0)),
                                    child: GestureDetector(
                                        child: Image.asset(
                                            "assets/images/reports/schoolReports.png"),
                                        onTap: () {
                                          Get.toNamed(
                                              '/schooladmin/reports/overall');
                                        }),
                                  ),
                                ),
                                Expanded(
                                  child: Container(
                                    margin: EdgeInsets.all(12),
                                    padding: EdgeInsets.all(12.0),
                                    decoration: BoxDecoration(
                                        color: Get.isDarkMode
                                            ? AppTheme.colors.darkTheme2
                                            : Colors.white.withOpacity(0.3),
                                        borderRadius:
                                            BorderRadius.circular(6.0)),
                                    child: GestureDetector(
                                        child: Image.asset(
                                            "assets/images/reports/classReports.png"),
                                        onTap: () {
                                          Get.toNamed(
                                              '/schooladmin/reports/class');
                                        }),
                                  ),
                                ),
                              ],
                            ),
                          ),
                          Expanded(
                            child: Row(
                              children: [
                                Expanded(
                                  child: Container(
                                    margin: EdgeInsets.all(12),
                                    //padding: EdgeInsets.all(12.0),
                                    decoration: BoxDecoration(
                                        color: Get.isDarkMode
                                            ? AppTheme.colors.darkTheme2
                                            : Colors.white.withOpacity(0.3),
                                        borderRadius:
                                            BorderRadius.circular(6.0)),
                                    child: GestureDetector(
                                        child: Image.asset(
                                            "assets/images/reports/studentReports.png"),
                                        onTap: () {
                                          Get.toNamed(
                                              '/schooladmin/reports/student');
                                        }),
                                  ),
                                ),
                                Expanded(
                                  child: Container(
                                    child: GestureDetector(),
                                  ),
                                ),
                              ],
                            ),
                          ),
                        ],
                      ),
                    ),
            ),
          ],
        ),
      ),
    );
  }
}
